#ifndef __MMLOADERSHELLCODE_H_INCLUDED_
#define __MMLOADERSHELLCODE_H_INCLUDED_
#pragma once
#include <windows.h>

/// <summary>
/// Function table. These function will be used in the mmLoader.
/// </summary>
typedef struct __NTFUNCPTRS
{
    LPVOID pfnCreateFileW;			//CreateFileW
    LPVOID pfnGetFileSize;			//GetFileSize
    LPVOID pfnCreateFileMappingW;	//CreateFileMappingW
    LPVOID pfnMapViewOfFile;		//MapViewOfFile
    LPVOID pfnUnmapViewOfFile;		//UnmapViewOfFile
    LPVOID pfnCloseHandle;			//CloseHandle
    LPVOID pfnGetModuleHandleA;		//GetModuleHandleA
    LPVOID pfnLoadLibraryA;			//LoadLibraryA
    LPVOID pfnGetProcAddress;		//GetProcAddress
    LPVOID pfnVirtualAlloc;			//VirtualAlloc
    LPVOID pfnVirtualFree;			//VirtualFree
    LPVOID pfnVirtualProtect;		//VirtualProtect
    LPVOID pfnReversed_0;
    LPVOID pfnReversed_1;
    LPVOID pfnReversed_2;
    LPVOID pfnReversed_3;
    LPVOID pfnReversed_4;
}NTFUNCPTRSTABLE, *PNTFUNCPTRSTABLE;

/// <summary>
/// Represents the memory module instance.
/// </summary>
typedef struct __MEMMODULE
{
    union								// MemModule base
    {
        DWORD	dwBase;
        HMODULE	hModule;
        LPVOID	lpBase;
        PIMAGE_DOS_HEADER pImageDosHeader;
    };
    DWORD dwSizeOfImage;				// MemModule size
    DWORD dwCrc;						// MemModule crc32

    BOOL	bLoadOk;					// MemModule is load ok?

    PNTFUNCPTRSTABLE pNtFuncptrsTable;	// Pointer to NT function pointers table 

    struct								// Raw file resource data
    {
        HANDLE	h;
        HANDLE	hMapping;
        LPVOID	pBuffer;
    }RawFile;

    TCHAR tszModuleName[MAX_PATH];		// MemModule Name (or full file path name)
}MEM_MODULE, *PMEM_MODULE;

/// <summary>
/// Enums for MemModuleHelper.
/// </summary>
typedef enum _MMHELPER_METHOD
{
    MHM_BOOL_LOAD,
    MHM_VOID_FREE,
    MHM_FARPROC_GETPROC,
}MMHELPER_METHOD;

/// <summary>
/// Type of the MemModuleHlper function.
/// </summary>
typedef int(__stdcall * Type_MemModuleHelper)(PMEM_MODULE, MMHELPER_METHOD, LPCTSTR, LPCSTR, BOOL);

/************************************************************************\
 *
 * Auxiliary Function:
 *		use the mmLoader through this function after it is loaded from shell code.
 *
 * Parameters:
 *		pMmeModule:
 *
 *		method:
 *			Function to be used
 *
 *		lpModuleName:
 *			name of the module to be loaded, only valid when method == MHM_BOOL_LOAD
 *			
 *		lpProcName:
 *			name of the proc to be retrieved, only valid when MHM_FARPROC_GETPROC
 *			
 *		bCallEntry:
 *			need to call the module entry point?
 *
 *	return value:
 *		when method == MHM_BOOL_LOAD
 *			return the resulT of loading, TRUE or FALSE
 *
 *		when method MHM_VOID_FREE:
 *			no return value
 *
 *		when method == MHM_FARPROC_GETPROC
 *			return the address of the target proc, return NULL when failed to get the address
 *
 *
 *
\************************************************************************/

/// <summary>
/// The byte array of the mmLoader shell code.
/// </summary>
unsigned char mmLoaderShellCode[] =
{
    0xE9, 0x09, 0x00, 0x00, 0x00, 0x6D, 0x6D, 0x6C, 0x53, 0xE9, 0xD2, 0x08, 0x00, 0x00, 0x55, 0x8B, 
    0xEC, 0x8B, 0x45, 0x0C, 0x83, 0xE8, 0x00, 0x74, 0x23, 0x83, 0xE8, 0x01, 0x74, 0x12, 0x83, 0xE8, 
    0x01, 0x75, 0x15, 0xFF, 0x75, 0x14, 0xFF, 0x75, 0x08, 0xE8, 0xF3, 0x00, 0x00, 0x00, 0xEB, 0x1A, 
    0xFF, 0x75, 0x08, 0xE8, 0x0D, 0x01, 0x00, 0x00, 0x33, 0xC0, 0xEB, 0x0E, 0xFF, 0x75, 0x18, 0xFF, 
    0x75, 0x10, 0xFF, 0x75, 0x08, 0xE8, 0x04, 0x00, 0x00, 0x00, 0x5D, 0xC2, 0x14, 0x00, 0x55, 0x8B, 
    0xEC, 0x56, 0x8B, 0x75, 0x08, 0x85, 0xF6, 0x0F, 0x84, 0xBD, 0x00, 0x00, 0x00, 0x83, 0x7E, 0x10, 
    0x00, 0x0F, 0x84, 0xB3, 0x00, 0x00, 0x00, 0x83, 0x7D, 0x0C, 0x00, 0x0F, 0x84, 0xA9, 0x00, 0x00, 
    0x00, 0x6A, 0x04, 0x6A, 0x00, 0x56, 0xE8, 0xCB, 0x07, 0x00, 0x00, 0x83, 0x4E, 0x14, 0xFF, 0x56, 
    0xFF, 0x75, 0x0C, 0xE8, 0xDF, 0x00, 0x00, 0x00, 0x83, 0xC4, 0x14, 0x85, 0xC0, 0x0F, 0x84, 0x87, 
    0x00, 0x00, 0x00, 0xFF, 0x76, 0x1C, 0xE8, 0x7C, 0x01, 0x00, 0x00, 0x59, 0x85, 0xC0, 0x74, 0x7A, 
    0x56, 0xE8, 0xDF, 0x01, 0x00, 0x00, 0x59, 0x85, 0xC0, 0x74, 0x6F, 0x56, 0xE8, 0xA3, 0x02, 0x00, 
    0x00, 0x59, 0x85, 0xC0, 0x74, 0x64, 0x56, 0xE8, 0xE7, 0x02, 0x00, 0x00, 0x59, 0x85, 0xC0, 0x74, 
    0x52, 0x56, 0xE8, 0x96, 0x03, 0x00, 0x00, 0x59, 0x85, 0xC0, 0x74, 0x47, 0x56, 0xE8, 0x58, 0x04, 
    0x00, 0x00, 0x59, 0x85, 0xC0, 0x74, 0x3C, 0x83, 0x7D, 0x10, 0x00, 0x74, 0x0E, 0x6A, 0x01, 0x56, 
    0xE8, 0x1D, 0x05, 0x00, 0x00, 0x59, 0x59, 0x85, 0xC0, 0x74, 0x28, 0xFF, 0x76, 0x04, 0xFF, 0x36, 
    0x6A, 0x00, 0xE8, 0xF9, 0x05, 0x00, 0x00, 0x68, 0x04, 0x01, 0x00, 0x00, 0xFF, 0x75, 0x0C, 0x8D, 
    0x4E, 0x20, 0x89, 0x46, 0x08, 0x51, 0xE8, 0x94, 0x07, 0x00, 0x00, 0x33, 0xC0, 0x83, 0xC4, 0x18, 
    0x40, 0xEB, 0x09, 0x56, 0xE8, 0x85, 0x05, 0x00, 0x00, 0x59, 0x33, 0xC0, 0x5E, 0x5D, 0xC2, 0x0C, 
    0x00, 0x55, 0x8B, 0xEC, 0x83, 0x7D, 0x08, 0x00, 0x74, 0x15, 0x83, 0x7D, 0x0C, 0x00, 0x74, 0x0F, 
    0xFF, 0x75, 0x0C, 0xFF, 0x75, 0x08, 0xE8, 0xF0, 0x04, 0x00, 0x00, 0x59, 0x59, 0xEB, 0x02, 0x33, 
    0xC0, 0x5D, 0xC2, 0x08, 0x00, 0x55, 0x8B, 0xEC, 0x83, 0x7D, 0x08, 0x00, 0x74, 0x15, 0x6A, 0x00, 
    0xFF, 0x75, 0x08, 0xE8, 0xAA, 0x04, 0x00, 0x00, 0xFF, 0x75, 0x08, 0xE8, 0x3E, 0x05, 0x00, 0x00, 
    0x83, 0xC4, 0x0C, 0x5D, 0xC2, 0x04, 0x00, 0x55, 0x8B, 0xEC, 0x56, 0x8B, 0x75, 0x0C, 0x85, 0xF6, 
    0x0F, 0x84, 0x9C, 0x00, 0x00, 0x00, 0x8B, 0x4E, 0x10, 0x85, 0xC9, 0x0F, 0x84, 0x91, 0x00, 0x00, 
    0x00, 0x8B, 0x51, 0x04, 0x8B, 0x01, 0x53, 0x8B, 0x59, 0x0C, 0x57, 0x8B, 0x79, 0x08, 0x33, 0xC9, 
    0x51, 0x51, 0x6A, 0x03, 0x51, 0x6A, 0x01, 0x68, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x75, 0x08, 0x89, 
    0x55, 0x0C, 0xFF, 0xD0, 0x33, 0xC9, 0x89, 0x46, 0x14, 0x83, 0xF8, 0xFF, 0x0F, 0x95, 0xC1, 0x83, 
    0xF8, 0xFF, 0x74, 0x58, 0x33, 0xC9, 0x85, 0xC0, 0x0F, 0x95, 0xC1, 0x85, 0xC0, 0x74, 0x4D, 0x6A, 
    0x00, 0x50, 0xFF, 0x55, 0x0C, 0x33, 0xC9, 0x83, 0xF8, 0xFF, 0x0F, 0x95, 0xC1, 0x85, 0xC9, 0x74, 
    0x3B, 0x6A, 0x40, 0x59, 0x3B, 0xC8, 0x1B, 0xC9, 0xF7, 0xD9, 0x74, 0x30, 0x33, 0xC0, 0x50, 0x50, 
    0x50, 0x6A, 0x02, 0x50, 0xFF, 0x76, 0x14, 0xFF, 0xD7, 0x33, 0xC9, 0x89, 0x46, 0x18, 0x85, 0xC0, 
    0x0F, 0x95, 0xC1, 0x85, 0xC0, 0x74, 0x15, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x04, 0x50, 
    0xFF, 0xD3, 0x33, 0xC9, 0x89, 0x46, 0x1C, 0x85, 0xC0, 0x0F, 0x95, 0xC1, 0x5F, 0x8B, 0xC1, 0x5B, 
    0xEB, 0x02, 0x33, 0xC0, 0x5E, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x8B, 0x4D, 0x08, 0x85, 0xC9, 0x75, 
    0x04, 0x33, 0xC0, 0x5D, 0xC3, 0x0F, 0xB7, 0x01, 0x33, 0xD2, 0x56, 0xBE, 0x4D, 0x5A, 0x00, 0x00, 
    0x66, 0x3B, 0xF0, 0x0F, 0x94, 0xC2, 0x66, 0x3B, 0xF0, 0x75, 0x45, 0x8B, 0x71, 0x3C, 0x33, 0xD2, 
    0x03, 0xF1, 0xB8, 0x50, 0x45, 0x00, 0x00, 0x39, 0x06, 0x0F, 0x94, 0xC2, 0x39, 0x06, 0x75, 0x30, 
    0x0F, 0xB7, 0x46, 0x04, 0xB9, 0x4C, 0x01, 0x00, 0x00, 0x33, 0xD2, 0x66, 0x3B, 0xC8, 0x0F, 0x94, 
    0xC2, 0x66, 0x3B, 0xC8, 0x75, 0x1A, 0x0F, 0xB7, 0x4E, 0x18, 0x33, 0xD2, 0xBE, 0x0B, 0x01, 0x00, 
    0x00, 0x66, 0x3B, 0xF1, 0x0F, 0x94, 0xC2, 0x33, 0xC0, 0x40, 0x66, 0x3B, 0xF1, 0x0F, 0x44, 0xD0, 
    0x8B, 0xC2, 0x5E, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x51, 0x51, 0x53, 0x56, 0x8B, 0x75, 0x08, 0x57, 
    0x85, 0xF6, 0x0F, 0x84, 0xB3, 0x00, 0x00, 0x00, 0x8B, 0x4E, 0x10, 0x85, 0xC9, 0x0F, 0x84, 0xA8, 
    0x00, 0x00, 0x00, 0x8B, 0x46, 0x1C, 0x85, 0xC0, 0x0F, 0x84, 0x9D, 0x00, 0x00, 0x00, 0x8B, 0x78, 
    0x3C, 0x8B, 0x59, 0x24, 0x03, 0xF8, 0x6A, 0x04, 0x68, 0x00, 0x30, 0x00, 0x00, 0x89, 0x7D, 0xF8, 
    0xFF, 0x77, 0x50, 0xFF, 0x77, 0x34, 0xFF, 0xD3, 0x89, 0x45, 0x08, 0x85, 0xC0, 0x75, 0x14, 0x6A, 
    0x04, 0x68, 0x00, 0x30, 0x00, 0x00, 0xFF, 0x77, 0x50, 0x50, 0xFF, 0xD3, 0x89, 0x45, 0x08, 0x85, 
    0xC0, 0x74, 0x68, 0xFF, 0x77, 0x54, 0xFF, 0x76, 0x1C, 0x50, 0xE8, 0x01, 0x05, 0x00, 0x00, 0x0F, 
    0xB7, 0x47, 0x06, 0x83, 0xC4, 0x0C, 0x89, 0x45, 0xFC, 0x85, 0xC0, 0x74, 0x3B, 0x8D, 0x9F, 0x08, 
    0x01, 0x00, 0x00, 0x8B, 0x7D, 0x08, 0x8B, 0x4B, 0xFC, 0x85, 0xC9, 0x74, 0x1D, 0x83, 0x3B, 0x00, 
    0x74, 0x18, 0xFF, 0x33, 0x8B, 0x43, 0x04, 0x03, 0x46, 0x1C, 0x50, 0x8D, 0x04, 0x39, 0x50, 0xE8, 
    0xCC, 0x04, 0x00, 0x00, 0x8B, 0x45, 0xFC, 0x83, 0xC4, 0x0C, 0x83, 0xC3, 0x28, 0x83, 0xE8, 0x01, 
    0x89, 0x45, 0xFC, 0x75, 0xD1, 0x8B, 0x7D, 0xF8, 0x8B, 0x45, 0x08, 0x89, 0x06, 0x8B, 0x47, 0x50, 
    0x89, 0x46, 0x04, 0x33, 0xC0, 0x40, 0x89, 0x46, 0x0C, 0xEB, 0x02, 0x33, 0xC0, 0x5F, 0x5E, 0x5B, 
    0x8B, 0xE5, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x56, 0x8B, 0x75, 0x08, 0x85, 0xF6, 0x74, 0x3F, 0x8B, 
    0x46, 0x10, 0x85, 0xC0, 0x74, 0x38, 0x83, 0x7E, 0x1C, 0x00, 0x57, 0x8B, 0x78, 0x14, 0x74, 0x0A, 
    0xFF, 0x76, 0x1C, 0xFF, 0x50, 0x10, 0x83, 0x66, 0x1C, 0x00, 0x83, 0x7E, 0x18, 0x00, 0x74, 0x09, 
    0xFF, 0x76, 0x18, 0xFF, 0xD7, 0x83, 0x66, 0x18, 0x00, 0x83, 0x7E, 0x14, 0x00, 0x74, 0x09, 0xFF, 
    0x76, 0x14, 0xFF, 0xD7, 0x83, 0x4E, 0x14, 0xFF, 0x33, 0xC0, 0x40, 0x5F, 0xEB, 0x02, 0x33, 0xC0, 
    0x5E, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x0C, 0x56, 0x8B, 0x75, 0x08, 0x85, 0xF6, 0x0F, 
    0x84, 0xA1, 0x00, 0x00, 0x00, 0x8B, 0x06, 0x85, 0xC0, 0x0F, 0x84, 0x97, 0x00, 0x00, 0x00, 0x8B, 
    0x48, 0x3C, 0x8B, 0xD0, 0x2B, 0x54, 0x01, 0x34, 0x89, 0x55, 0xFC, 0x75, 0x08, 0x33, 0xC0, 0x40, 
    0xE9, 0x83, 0x00, 0x00, 0x00, 0x8B, 0x94, 0x01, 0xA0, 0x00, 0x00, 0x00, 0x85, 0xD2, 0x74, 0xED, 
    0x83, 0xBC, 0x01, 0xA4, 0x00, 0x00, 0x00, 0x00, 0x74, 0xE3, 0x8D, 0x0C, 0x02, 0x85, 0xC9, 0x74, 
    0x65, 0x8B, 0x01, 0x57, 0x8D, 0x79, 0x04, 0x8B, 0x17, 0x89, 0x7D, 0x08, 0x03, 0xC2, 0x74, 0x50, 
    0x53, 0x8D, 0x42, 0xF8, 0xD1, 0xE8, 0x6A, 0x00, 0x89, 0x45, 0xF4, 0x5B, 0x74, 0x31, 0x8B, 0x7D, 
    0xFC, 0x0F, 0xB7, 0x54, 0x59, 0x08, 0x8B, 0xC2, 0xC7, 0x45, 0xF8, 0x00, 0x30, 0x00, 0x00, 0x25, 
    0x00, 0xF0, 0x00, 0x00, 0x66, 0x39, 0x45, 0xF8, 0x75, 0x0C, 0x81, 0xE2, 0xFF, 0x0F, 0x00, 0x00, 
    0x03, 0x11, 0x03, 0x16, 0x01, 0x3A, 0x43, 0x3B, 0x5D, 0xF4, 0x7C, 0xD5, 0x8B, 0x7D, 0x08, 0x03, 
    0x0F, 0x8B, 0x01, 0x8D, 0x79, 0x04, 0x8B, 0x17, 0x89, 0x7D, 0x08, 0x03, 0xC2, 0x75, 0xB2, 0x5B, 
    0x33, 0xC0, 0x40, 0x5F, 0xEB, 0x02, 0x33, 0xC0, 0x5E, 0x8B, 0xE5, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 
    0x83, 0xEC, 0x14, 0x53, 0x56, 0x8B, 0x75, 0x08, 0x57, 0x85, 0xF6, 0x0F, 0x84, 0xB0, 0x00, 0x00, 
    0x00, 0x8B, 0x46, 0x10, 0x85, 0xC0, 0x0F, 0x84, 0xA5, 0x00, 0x00, 0x00, 0x8B, 0x0E, 0x85, 0xC9, 
    0x0F, 0x84, 0x9B, 0x00, 0x00, 0x00, 0x8B, 0x50, 0x18, 0x89, 0x55, 0xF0, 0x8B, 0x50, 0x1C, 0x8B, 
    0x40, 0x20, 0x89, 0x45, 0xFC, 0x8B, 0x41, 0x3C, 0x89, 0x55, 0xEC, 0x8B, 0x94, 0x08, 0x80, 0x00, 
    0x00, 0x00, 0x85, 0xD2, 0x74, 0x76, 0x83, 0xBC, 0x08, 0x84, 0x00, 0x00, 0x00, 0x00, 0x74, 0x6C, 
    0x8D, 0x3C, 0x0A, 0xEB, 0x5F, 0x8B, 0x5F, 0x0C, 0x03, 0x1E, 0x53, 0xFF, 0x55, 0xF0, 0x89, 0x45, 
    0x08, 0x85, 0xC0, 0x75, 0x0B, 0x53, 0xFF, 0x55, 0xEC, 0x89, 0x45, 0x08, 0x85, 0xC0, 0x74, 0x51, 
    0x8B, 0x1F, 0x03, 0x1E, 0x8B, 0x47, 0x10, 0x03, 0x06, 0x89, 0x45, 0xF8, 0x8B, 0x0B, 0x85, 0xC9, 
    0x74, 0x2F, 0x8B, 0x7D, 0x08, 0x79, 0x05, 0x0F, 0xB7, 0xC1, 0xEB, 0x07, 0x8B, 0x06, 0x83, 0xC0, 
    0x02, 0x03, 0xC1, 0x50, 0x57, 0xFF, 0x55, 0xFC, 0x8B, 0xC8, 0x83, 0xC3, 0x04, 0x8B, 0x45, 0xF8, 
    0x89, 0x08, 0x83, 0xC0, 0x04, 0x8B, 0x0B, 0x89, 0x45, 0xF8, 0x85, 0xC9, 0x75, 0xD7, 0x8B, 0x7D, 
    0xF4, 0x83, 0xC7, 0x14, 0x83, 0x3F, 0x00, 0x89, 0x7D, 0xF4, 0x75, 0x99, 0x33, 0xC0, 0x40, 0xEB, 
    0x02, 0x33, 0xC0, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x10, 
    0x53, 0x8B, 0x5D, 0x08, 0x56, 0x57, 0x85, 0xDB, 0x0F, 0x84, 0xBB, 0x00, 0x00, 0x00, 0x8B, 0x43, 
    0x10, 0x85, 0xC0, 0x0F, 0x84, 0xB0, 0x00, 0x00, 0x00, 0x8B, 0x40, 0x2C, 0x33, 0xC9, 0x89, 0x45, 
    0xF8, 0x33, 0xD2, 0x8B, 0x03, 0x8B, 0x78, 0x3C, 0x03, 0xF8, 0x33, 0xC0, 0x89, 0x45, 0x08, 0x0F, 
    0xB7, 0x77, 0x06, 0x89, 0x75, 0xF0, 0x85, 0xF6, 0x0F, 0x84, 0x86, 0x00, 0x00, 0x00, 0x81, 0xC7, 
    0x08, 0x01, 0x00, 0x00, 0x83, 0x7F, 0xFC, 0x00, 0x74, 0x6F, 0x83, 0x3F, 0x00, 0x74, 0x6A, 0x8B, 
    0x47, 0x14, 0x8B, 0xF0, 0xA9, 0x00, 0x00, 0x00, 0x20, 0x74, 0x19, 0x81, 0xE6, 0x00, 0x00, 0x00, 
    0x40, 0xF7, 0xDE, 0x1B, 0xF6, 0x83, 0xE6, 0x10, 0x83, 0xC6, 0x10, 0x85, 0xC0, 0x79, 0x18, 0x6A, 
    0x40, 0x5E, 0xEB, 0x13, 0xC1, 0xEE, 0x1D, 0x83, 0xE6, 0x02, 0xC7, 0x45, 0xFC, 0x04, 0x00, 0x00, 
    0x00, 0x85, 0xC0, 0x0F, 0x48, 0x75, 0xFC, 0x8B, 0x03, 0x03, 0x47, 0xFC, 0x89, 0x45, 0xF4, 0x3B, 
    0xC1, 0x77, 0x06, 0xF6, 0xC2, 0x44, 0x0F, 0x45, 0xF2, 0x83, 0x65, 0xFC, 0x00, 0x8D, 0x4D, 0xFC, 
    0x51, 0x56, 0xFF, 0x37, 0x50, 0xFF, 0x55, 0xF8, 0x85, 0xC0, 0x74, 0x1D, 0x8B, 0x0F, 0x8B, 0xD6, 
    0x03, 0x4D, 0xF4, 0x8B, 0x45, 0x08, 0x8B, 0x75, 0xF0, 0x40, 0x83, 0xC7, 0x28, 0x89, 0x45, 0x08, 
    0x3B, 0xC6, 0x7C, 0x80, 0x33, 0xC0, 0x40, 0xEB, 0x02, 0x33, 0xC0, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 
    0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x8B, 0x4D, 0x08, 0x85, 0xC9, 0x74, 0x1B, 0x8B, 0x09, 0x85, 0xC9, 
    0x74, 0x15, 0x8B, 0x41, 0x3C, 0x8B, 0x44, 0x08, 0x28, 0x03, 0xC1, 0x74, 0x0A, 0x6A, 0x00, 0xFF, 
    0x75, 0x0C, 0x51, 0xFF, 0xD0, 0x5D, 0xC3, 0x33, 0xC0, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x51, 0x51, 
    0x53, 0x56, 0x8B, 0x75, 0x08, 0x57, 0x85, 0xF6, 0x74, 0x4D, 0x8B, 0x36, 0x85, 0xF6, 0x74, 0x47, 
    0x8B, 0x46, 0x3C, 0x33, 0xFF, 0x8B, 0x44, 0x30, 0x78, 0x03, 0xC6, 0x8B, 0x50, 0x20, 0x8B, 0x58, 
    0x24, 0x03, 0xD6, 0x8B, 0x48, 0x1C, 0x03, 0xDE, 0x8B, 0x40, 0x14, 0x03, 0xCE, 0x89, 0x55, 0xFC, 
    0x89, 0x4D, 0xF8, 0x89, 0x45, 0x08, 0x85, 0xC0, 0x7E, 0x1D, 0x8B, 0x04, 0xBA, 0x03, 0xC6, 0x50, 
    0xFF, 0x75, 0x0C, 0xE8, 0xFB, 0x01, 0x00, 0x00, 0x59, 0x59, 0x85, 0xC0, 0x74, 0x12, 0x8B, 0x55, 
    0xFC, 0x47, 0x3B, 0x7D, 0x08, 0x7C, 0xE3, 0x33, 0xC0, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3, 
    0x0F, 0xB7, 0x04, 0x7B, 0x8B, 0x4D, 0xF8, 0x8B, 0x04, 0x81, 0x03, 0xC6, 0xEB, 0xEB, 0x55, 0x8B, 
    0xEC, 0x56, 0x8B, 0x75, 0x08, 0x85, 0xF6, 0x74, 0x3C, 0x8B, 0x46, 0x10, 0x85, 0xC0, 0x74, 0x35, 
    0x57, 0x33, 0xFF, 0x39, 0x7E, 0x0C, 0x74, 0x2C, 0x39, 0x3E, 0x74, 0x28, 0x68, 0x00, 0x80, 0x00, 
    0x00, 0x57, 0xFF, 0x36, 0xFF, 0x50, 0x28, 0x68, 0x08, 0x02, 0x00, 0x00, 0x8D, 0x46, 0x20, 0x89, 
    0x3E, 0x57, 0x50, 0x89, 0x7E, 0x08, 0x89, 0x7E, 0x04, 0x89, 0x7E, 0x0C, 0xE8, 0x65, 0x01, 0x00, 
    0x00, 0x83, 0xC4, 0x0C, 0x5F, 0x5E, 0x5D, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 
    0x81, 0xEC, 0x00, 0x04, 0x00, 0x00, 0x33, 0xC9, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x8B, 0xC1, 0xC1, 0xE0, 0x18, 0x3D, 0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 
    0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 0xC0, 0x3D, 0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 
    0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 0xC0, 0x3D, 0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 
    0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 0xC0, 0x3D, 0x00, 0x00, 0x00, 0x80, 
    0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 0xC0, 0x3D, 0x00, 0x00, 
    0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 0xC0, 0x3D, 
    0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 0x02, 0x03, 
    0xC0, 0x3D, 0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 0x04, 0xEB, 
    0x02, 0x03, 0xC0, 0x3D, 0x00, 0x00, 0x00, 0x80, 0x72, 0x09, 0x03, 0xC0, 0x35, 0xB7, 0x0D, 0xC1, 
    0x04, 0xEB, 0x02, 0x03, 0xC0, 0x89, 0x04, 0x8C, 0x41, 0x81, 0xF9, 0x00, 0x01, 0x00, 0x00, 0x0F, 
    0x8C, 0x5B, 0xFF, 0xFF, 0xFF, 0x8B, 0x94, 0x24, 0x04, 0x04, 0x00, 0x00, 0x56, 0x8B, 0xB4, 0x24, 
    0x10, 0x04, 0x00, 0x00, 0x57, 0x8B, 0xBC, 0x24, 0x10, 0x04, 0x00, 0x00, 0x85, 0xF6, 0x74, 0x19, 
    0x0F, 0xB6, 0x07, 0x8D, 0x7F, 0x01, 0x8B, 0xCA, 0xC1, 0xE2, 0x08, 0xC1, 0xE9, 0x18, 0x33, 0xC8, 
    0x33, 0x54, 0x8C, 0x08, 0x83, 0xEE, 0x01, 0x75, 0xE7, 0x5F, 0x8B, 0xC2, 0x5E, 0x81, 0xC4, 0x00, 
    0x04, 0x00, 0x00, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 
    0x8B, 0x54, 0x24, 0x04, 0x56, 0x8B, 0x74, 0x24, 0x0C, 0x57, 0x3B, 0xF2, 0x73, 0x27, 0x8B, 0x7C, 
    0x24, 0x14, 0x4E, 0x03, 0xF7, 0x8D, 0x47, 0xFF, 0x03, 0xC2, 0x85, 0xFF, 0x74, 0x33, 0x66, 0x90, 
    0x8A, 0x0E, 0x8D, 0x40, 0xFF, 0x88, 0x48, 0x01, 0x8D, 0x76, 0xFF, 0x83, 0xEF, 0x01, 0x75, 0xF0, 
    0x5F, 0x8B, 0xC2, 0x5E, 0xC3, 0x76, 0x1A, 0x8B, 0x7C, 0x24, 0x14, 0x8B, 0xCA, 0x85, 0xFF, 0x74, 
    0x10, 0x2B, 0xF2, 0x8A, 0x04, 0x0E, 0x8D, 0x49, 0x01, 0x88, 0x41, 0xFF, 0x83, 0xEF, 0x01, 0x75, 
    0xF2, 0x5F, 0x8B, 0xC2, 0x5E, 0xC3, 0x55, 0x8B, 0xEC, 0x51, 0x83, 0x65, 0xFC, 0x00, 0xEB, 0x07, 
    0x8B, 0x45, 0xFC, 0x40, 0x89, 0x45, 0xFC, 0x8B, 0x45, 0xFC, 0x3B, 0x45, 0x10, 0x73, 0x0D, 0x8B, 
    0x45, 0x08, 0x03, 0x45, 0xFC, 0x8A, 0x4D, 0x0C, 0x88, 0x08, 0xEB, 0xE4, 0x8B, 0x45, 0x08, 0x8B, 
    0xE5, 0x5D, 0xC3, 0x55, 0x8B, 0xEC, 0x8B, 0x4D, 0x08, 0x8B, 0x45, 0x0C, 0x2B, 0xC8, 0x53, 0x8A, 
    0x1C, 0x01, 0x8A, 0x10, 0x40, 0x84, 0xDB, 0x74, 0x0E, 0x3A, 0xDA, 0x74, 0xF2, 0x0F, 0xB6, 0xCA, 
    0x0F, 0xB6, 0xC3, 0x2B, 0xC1, 0xEB, 0x05, 0x0F, 0xB6, 0xC2, 0xF7, 0xD8, 0x5B, 0x5D, 0xC3, 0x55, 
    0x8B, 0xEC, 0x8B, 0x55, 0x10, 0x8B, 0x4D, 0x08, 0x56, 0x57, 0x85, 0xD2, 0x74, 0x1E, 0x8B, 0x75, 
    0x0C, 0x0F, 0xB7, 0x3E, 0x2B, 0xF1, 0x66, 0x89, 0x39, 0x4A, 0x83, 0xC1, 0x02, 0x0F, 0xB7, 0x04, 
    0x0E, 0x8B, 0xF8, 0x66, 0x85, 0xC0, 0x74, 0x04, 0x85, 0xD2, 0x75, 0xEA, 0x5F, 0x8B, 0xC1, 0x5E, 
    0x5D, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 

};

/************************************************************************
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include "mmLoaderShellCode.h"

int main()
{
    // Function table
    NTFUNCPTRSTABLE sNtFuncPtrsTable;
    sNtFuncPtrsTable.pfnCreateFileW = CreateFileW;
    sNtFuncPtrsTable.pfnGetFileSize = GetFileSize;
    sNtFuncPtrsTable.pfnCreateFileMappingW = CreateFileMappingW;
    sNtFuncPtrsTable.pfnMapViewOfFile = MapViewOfFile;
    sNtFuncPtrsTable.pfnUnmapViewOfFile = UnmapViewOfFile;
    sNtFuncPtrsTable.pfnCloseHandle = CloseHandle;
    sNtFuncPtrsTable.pfnGetModuleHandleA = GetModuleHandleA;
    sNtFuncPtrsTable.pfnLoadLibraryA = LoadLibraryA;
    sNtFuncPtrsTable.pfnGetProcAddress = GetProcAddress;
    sNtFuncPtrsTable.pfnVirtualAlloc = VirtualAlloc;
    sNtFuncPtrsTable.pfnVirtualFree = VirtualFree;
    sNtFuncPtrsTable.pfnVirtualProtect = VirtualProtect;

    // Memory module
    MEM_MODULE sMemModule;
    ::RtlZeroMemory(&sMemModule, sizeof(sMemModule));
    sMemModule.RawFile.h = INVALID_HANDLE_VALUE;
    sMemModule.pNtFuncptrsTable = &sNtFuncPtrsTable;

    // Allocate memory buffer for shell code with EXECUTE privilege
    LPVOID  lpShellCodeBase = ::VirtualAlloc(
        NULL,
        sizeof(mmLoaderShellCode),
        MEM_RESERVE | MEM_COMMIT,
        PAGE_EXECUTE_READWRITE);

    if (NULL == lpShellCodeBase)
    {
        ::_tprintf(_T("Failed to allocate space for ShellCode!\r\n"));
        return FALSE;
    }

    // Copy shell code to the executable memory buffer
    ::RtlCopyMemory(lpShellCodeBase, mmLoaderShellCode, sizeof(mmLoaderShellCode));

    // Get the helper function 
    Type_MemModuleHelper pfnMemModuleHelper = (Type_MemModuleHelper)lpShellCodeBase;

    // Load user32.dll
    TCHAR tszDllPath[] = _T("C:\\windows\\system32\\user32.dll");
    if (pfnMemModuleHelper(&sMemModule, MHM_BOOL_LOAD, tszDllPath, NULL, FALSE))
    {
        _tprintf(_T("Load user32.dll successfully.Module Base : 0x%08X!\r\n"), sMemModule.dwBase);

        // Get address of function MessageBoxA
        LPVOID lpAddr = (LPVOID)pfnMemModuleHelper(&sMemModule, MHM_FARPROC_GETPROC, NULL, "MessageBoxA", FALSE);\r\n		if (lpAddr)
        {
            _tprintf(_T("Get address of MessageBoxA successfully.Address: 0x%p!\r\n"), lpAddr);

            // Function pointer type of MessageBoxA
            typedef int (WINAPI * Type_MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT);

            // Call the MessageBoxA
            Type_MessageBoxA pfnMessageBoxA = (Type_MessageBoxA)lpAddr;
            pfnMessageBoxA(NULL, "This message box is displayed by calling the code in memory module.", NULL, MB_OK);
        }
        else
            _tprintf(_T("Failed to get address of MessageBoxA from memory module\r\n."));

        // Free the module
        pfnMemModuleHelper(&sMemModule, MHM_VOID_FREE, NULL, NULL, FALSE);
    }
    else
        _tprintf(_T("Failed to load user32.dll!\r\n"));

    // Free the memory buffer of the shell code
    ::VirtualFree(lpShellCodeBase, 0, MEM_RELEASE);

    return 0;
}
************************************************************************/

#endif // __MMLOADERSHELLCODE_H_INCLUDED_